<?php
/**
 * @author baby&star
 *
 *
 */
class ProductsController extends Controller{
	//TODO - Insert your code here
	function actionIndex(){
		$wh = "";
		if($_POST){
			$wh = " and `name` like '%".$_POST['keyword']."%'";
		}
		$page = isset($_GET["page"])&&$_GET["page"]>0?$_GET["page"]:1;
		$brand = new brand_products();
		$brand->setName("products");
		$data = $brand->getList("`deleted` = 0 ".$wh,"id desc",$page,$this->createUrl("products/index"),6);
		
		//print_r($data);
		$this->render("index",array("data"=>$data));
	}
	
	function actionDelete(){
		$id = $_GET["id"];
		if(!is_numeric($id)){
			Common::jsalerturl("非法操作！");
			exit;
		}
		$brand = new brand_products();
		$brand->setName("products");
		$brand->del("`id` = '".$id."'");
		Common::jsalerturl("删除成功！");
	}
}


?>